package com.niuxiaofa.newlaw;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;

import androidx.multidex.MultiDex;

import com.niuxiaofa.newlaw.Tools.TTAdManagerHolder;
import com.scwang.smart.refresh.footer.BallPulseFooter;
import com.scwang.smart.refresh.header.BezierRadarHeader;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshFooter;
import com.scwang.smart.refresh.layout.api.RefreshHeader;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.DefaultRefreshFooterCreator;
import com.scwang.smart.refresh.layout.listener.DefaultRefreshHeaderCreator;

/**
 * @ClassName MyApplication
 * @Description TODO
 * @Author Gxjkz
 * @Date 2020/8/31 10:18
 * @Version 1
 * .0
 */
public class MyApplication extends Application {

    String ugcLicenceUrl = "请替换成您的licenseUrl";
    String ugcKey = "请替换成您的licenseKey";


    public static Application mApplication;
    @Override
    public void onCreate() {
        super.onCreate();

        TTAdManagerHolder.init(this);

      //TXUGCBase.getInstance().setLicence(this, ugcLicenceUrl, ugcKey);

        // 短视频licence设置
        StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
        StrictMode.setVmPolicy(builder.build());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            builder.detectFileUriExposure();
        }


        registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
            @Override
            public void onActivityCreated(Activity activity, Bundle savedInstanceState) {

            }

            @Override
            public void onActivityStarted(Activity activity) {

            }

            @Override
            public void onActivityResumed(Activity activity) {


            }

            @Override
            public void onActivityPaused(Activity activity) {

            }

            @Override
            public void onActivityStopped(Activity activity) {

            }

            @Override
            public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

            }

            @Override
            public void onActivityDestroyed(Activity activity) {



            }
        });
        mApplication = this;
        MultiDex.install(this);

//        // 通过WXAPIFactory工厂，获取IWXAPI的实例
//        Constant.wx_api = WXAPIFactory.createWXAPI(getApplicationContext(), Constant.WX_APPID, true);
//        // 将应用的appId注册到微信
//        Constant.wx_api.registerApp(Constant.WX_APPID);


    }


    //static 代码段可以防止内存泄露
    static {
        //设置全局的Header构建器
        SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
            @Override
            public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
                layout.setPrimaryColorsId(R.color.colorPrimaryHalf, android.R.color.white);//全局设置主题颜色
                return new  BezierRadarHeader(context).setEnableHorizontalDrag(true);//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header，默认是 贝塞尔雷达Header
            }
        });


        //设置全局的Footer构建器
        SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
            @Override
            public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
                //指定为经典Footer，默认是 BallPulseFooter
//                return new ClassicsFooter(context).setDrawableSize(20);
                return new BallPulseFooter(context);
            }
        });
    }


}
